class Animal {
    // public name: string;
    // readonly name: string;
    // private  name: string; //子类不可以访问。
    protected name: string; //子类可以访问。
    static categoies: string[] = ['mammal', 'bird'];
    static isAnimal(a) {
        return a instanceof Animal
    }
    constructor(name: string) {
        this.name = name
    }
    run() {
        return `${this.name} is running.`
    }
}

const snake = new Animal('king')
console.log(snake.name)
console.log(Animal.isAnimal(snake))
console.log(Animal.categoies)
snake.name = "lucy"
console.log(snake.name)
console.log(snake.run())

class dog extends Animal {
    bark() {
        return `${this.name} is barking!`
    }

}
const erhu = new dog('erhu')
console.log(erhu.bark())
console.log(erhu.run())

class cat extends Animal {
    constructor(name: string) {
        super(name)
        // this.name=name
        console.log(name)
    }
    run() {
        // return `miao,miao,${this.name} is running`
        return 'miao,' + super.run()
    }
}
const cate = new cat('mm')
console.log(cate.run())